
#pragma once


#include <Arduino.h>


namespace scheduler_basic {

    class ArduinoTimeoutCounter {
       public:
        using TimeType = uint32_t;

       private:
        TimeType _interval;
        TimeType _when_start;

       public:
        explicit ArduinoUsTimeoutCounter(TimeType interval) :
            _interval(interval) {}

        void start() {
            _when_start = micros();
        }

        bool expired() const {
            return _interval < (micros() - _when_start);
        }

        bool disabled() const {
            return _interval == 0;
        }

        TimeType get() const {
            return _interval;
        }

        void set(TimeType interval) {
            _interval = interval;
        }
    };


}  // namespace scheduler_basic
